<?php 
	session_start();
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
    
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <title>Thomson</title>
	<link rel="stylesheet" type="text/css" href="css/demo.css" media="screen" />
	<link rel="stylesheet" href="css/button.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="css/navigation.css" type="text/css" media="screen" />
		<script type="text/javascript" src="js/jquery.js"></script>   
    
</head>
<?php
	
	include_once('process\database.php');
	include_once('process\product.php');
	include_once('process\login.php');
	include_once('process\productOption.php');
	include_once('process\productVote.php');
	include_once ('process\facebook.php');
	include_once ('process\db.inc');
	include_once ('process\face.inc');
	$user_th = new user();
	$product = new product();
	$productVote = new productVote();
	$productOption = new productOption();
	$count = count($product->show_product());

		$facebook = new Facebook(array(
		  	'appId'  => $face['appID'],
		  	'secret' => $face['secret'],
			'cookie' => true, // this!
			'oauth' => true	
		));

	$user = $facebook->getUser();
	if ($user) {
	  try {
	    // Proceed knowing you have a logged in user who's authenticated.
	    $user_profile = $facebook->api('/'.$user);
	    $usernames = $user_th->get_user();
	    $usernameArr = array();
	    foreach ($usernames as $username)
	    {
	    	$username_db = $username['username'];
	    	$usernameArr[] = $username_db;    	
	    }
	    $username_face = $user_profile['username'];
	    if(!in_array($username_face, $usernameArr))
	    {
	    	$user_th->insert_user($user_profile['username'], md5(123), $user_profile['id'], $user_profile['first_name'], $user_profile['last_name'], $user_profile['gender'], $user_profile['locale'], 0);
	    }	    
	  } catch (FacebookApiException $e) {
	   		error_log($e);
	    	$user = null;
	  }
	}	
	// Login or logout url will be needed depending on current user state.
	if ($user) {
	  $logoutUrl = $facebook->getLogoutUrl();
	  
	} else {
	  $loginUrl = $facebook->getLoginUrl();
	}
	//$user_info = $facebook->api('/'.$user);
	//print_r($user_info);
?>
<body>
<script language="javascript">
$(document).ready(function () {
	$("ul.subnav").parent().append("<span></span>");
    $('a.aaa').hover(function () {
		$(this).parent().find("ul.subnav").slideDown('fast').show();
		$(this).parent().hover(function() {
		},function(){
			$(this).parent().find("ul.subnav").slideUp('slow');
		});
	}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); 
	});
});

function ReturnDropDownValue(divname) { 
    
    if(document.getElementById(divname)!=null){
        //return document.getElementById(divname).value;
        var dropdownIndex = document.getElementById(divname).selectedIndex;
        return document.getElementById(divname)[dropdownIndex].value;
    }
    else
        return "";
}
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '<?php echo $face['appID']?>', // App ID
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));

  (function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
</script>


<div id ="wrap">

	<div class="top-header-wrapper container">
		<a class="header-logo" title="Thomson Catering" href="index.aspx"></a>
		<div id ="header"></div>
			<div id="navigation-tabs">
                <ul class="topnav">
           			<li><a title="About Us" href="#">About Us</a></li>
            		<li> <a title="Our Menu" href="#">Our Menu</a></li>
           			<li><a title="Promotions" href="#">Promotions</a></li>
            		<li> <a title="Event Gallery" href="#">Event Gallery</a></li>
            		<li>
                		<p class="img"></p><a href="#" class="aaa">Services</a>
                		<ul class="subnav">
		                    <li>                       
		                        <a title="Canteen Services" class="level1" href="#">Canteen Services</a>
		                   </li>
		                   <li>
			                   <a title="Corporate Catering" class="level1" href="#">Corporate Catering</a>
		                   </li>
		                   <li>
			                   <a title="Other Services" class="level1" href="#">Other Services</a>
		                   </li>
                		</ul>
            		</li>
            		<li><a title="Testimonials" href="#">Testimonials</a></li>            
        		</ul>
			</div>
		<div class="banner-wrapper" currentbanner="2">

            <div class="banner-content-wrapper">
				<h2 class="banner-title">
		             Service Excellent<br>
		             <span>100% reliable</span>
		        </h2>
                <p class="banner-content">
                    Let us take care of <b>your</b> important day
                    <a title="Read more" href="#">Read more &gt;&gt;</a>
                </p>
            </div>

            <div style="z-index: 3; background: url(images/banner-wrapper-1.jpg&quot;) no-repeat scroll 0px 0px transparent; opacity: 0;" class="banner-1 banner-image"></div>
            <div style="z-index: 2; background: url(images/banner-wrapper-2.jpg&quot;) no-repeat scroll 0px 0px transparent; opacity: 1;" class="banner-2 banner-image"></div>
            <div style="z-index:1; background : url(images/banner-wrapper-3.jpg) no-repeat 0 0 transparent;" class="banner-3 banner-image"></div>

            <ul class="banner-customize">
                <li class="link-1"><span class="bullet"></span><a title="Service" onclick="bannerLinkClick(1)" href="javascript:;">
                    &nbsp;</a></li>
                <li class="link-2 selected"><span class="bullet"></span><a title="New Menu" onclick="bannerLinkClick(2)" href="javascript:;">
                    &nbsp;</a></li>
                <li class="link-3"><span class="bullet"></span><a title="Promotion" onclick="bannerLinkClick(3)" href="javascript:;">
                    &nbsp;</a></li>
            </ul>
        </div>
	</div>
	<div class="content-title">
            <h2>Our Menu <span class="description">Items 1 to <?php echo $count;?> out of <?php echo $count;?> total</span></h2>  
          
     </div>
	<div class="content-l">
		<div class="content-tabs">
	        <ul>
	         	<li onclick="location.href='index.php?func=product';" class="selected"><a title="Packages" href="index.php?func=product">Packages</a></li>
	            <li onclick="location.href='#';" title="A La Carte"><a href="#">A La Carte</a></li>
	           	<li onclick="location.href='#';"><a title="Promotions" href="#">Promotions</a></li>
	            <li onclick="location.href='#';"><a title="Latest News" href="#">Latest News</a></li>
	       </ul>
	    </div>
		<div class="">
			<?php 
				if(isset($_GET['func'])&& $_GET['func'] == 'pruduct')
				{
					include('product.php');
				}
				elseif(isset($_GET['func'])&& $_GET['func'] == 'product_detail')
				{
					include('productDetail.php');
				}
				else 
				{
					include('product.php');
				}
			?>                            
		</div>
	</div>
	<div class="content-r">
		<img alt="Sales Hotline" src="images/sales-hotline.png" />
    <?php if ($user): ?>
     	
     	<div style=" padding: 22px 0; text-align:left;">
     		<div style="text-align:center; float: left;">
     			<img src="https://graph.facebook.com/<?php echo $user; ?>/picture" />
     		</div>
     		<div style="color: rgb(59, 89, 152); font-weight: bold; padding-left: 56px;">
     			<?php  echo $user_profile['name'] ?>
     			<p></p>
     			<?php else: ?>
			      <strong"><em> </em></strong></br>
			    <?php endif ?>
				<?php if ($user) {?>
			      	<a href="<?php echo $logoutUrl; ?>" >Logout</a>
			    <?php }else{ ?>   		
			       	<a href="<?php echo $loginUrl; ?>" style=" background-color: #DA8109;border: 1px solid #FFFFFF;border-radius: 5px 5px 5px 5px;color: white;float: left;line-height: 21px;padding: 5px;">
			       		Login with Facebook
			       	</a>
			   	<?php }?>
    		</div>
    	
     	</div>	
			   
		<div style="text-align:left;">
			
	    	<img alt="Facebook" src="images/fb-head.png" width="192" />
	    </div>
	    <div style="text-align:left;">
	    	<iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FWebsite-food%2F390188511042955%3Fsk%3Dapp_156218351098324&amp;width=292&amp;height=290&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=false&amp;header=true&amp;appId=104902649655130" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:192px; height:290px;" allowTransparency="true"></iframe>
		</div>  
	</div>
	<div style="clear: both;"></div>
</div>
<div class="footer-wrapper">
        <div class="container">
            <a title="Thomson Catering" class="footer-logo" href="http://www.thomsoncatering.com.sg/index.aspx?st=pr"></a>
            <div class="meta-footer-wrapper">
                <ul class="meta-footer">
                    <li class="first"><a title="About Us" href="http://www.thomsoncatering.com.sg/about-us.aspx">About Us</a></li>
                    <li><a title="Our Menu" href="http://www.thomsoncatering.com.sg/index.aspx">Our Menu</a></li>
                    <li><a title="Canteen Services" href="http://www.thomsoncatering.com.sg/service-canteen.aspx">Canteen Services</a></li>
                    <li><a title="Other Services" href="http://www.thomsoncatering.com.sg/service-others.aspx">Other Services</a></li>
                    <li><a title="Promotions" href="http://www.thomsoncatering.com.sg/index.aspx?st=pr">Promotions</a></li>
                    <li><a title="Event Gallery" href="http://www.thomsoncatering.com.sg/event-listing.aspx">Event Gallery</a></li>
                    <li><a title="Careers" href="http://www.thomsoncatering.com.sg/about-us.aspx#tab=career">Careers</a></li>
                    <li><a title="Contact Us" href="http://www.thomsoncatering.com.sg/contact-us.aspx">Contact Us</a></li>
                </ul>
                <p class="footer-desc">All prices are in SGD. Copyright 2010 Thomson Catering Pte Ltd.</p>
            </div>
        </div>
    </div>
  </body>
</html>
